import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'CountModel.dart';
import 'ScopedTwo.dart';

class ScopedOne extends StatefulWidget {
  @override
  _OneState createState() => _OneState();
}

class _OneState extends State<ScopedOne> {

//  final countModel = CountModel().of(context);
  @override
  Widget build(BuildContext context) {
    return ScopedModelDescendant<CountModel>(
      builder: (context, child, model) {
        return Scaffold(
          appBar: AppBar(
            title: Text("Scoped测试首页"),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () => model.increment(),
            child: Icon(Icons.add),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  model.count.toString(),
                  style: TextStyle(fontSize: 26, color: Colors.red[400]),
                ),
                RaisedButton(
                  child: Text(
                    "下一页",
                    style: TextStyle(color: Colors.orange[500], fontSize: 16),
                  ),
                  onPressed: () {
                    Navigator.push(
                        context,
                        new MaterialPageRoute(
                            builder: (context) => new ScopedTwo()));
                  },
                )
              ],
            ),
          ),
        );
      },
    );
  }
}
